package com.yeyks.commonReference.service.hotel.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yeyks.account.dal.domain.AccountInfo;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.appcommon.dto.account.AppAccountDTO;
import com.yeyks.common.appcommon.dto.room.AppRoomBedTypeDTO;
import com.yeyks.common.appcommon.dto.room.AppRoomDetailInfoDTO;
import com.yeyks.common.appcommon.dto.room.AppRoomDevicesDTO;
import com.yeyks.common.appcommon.dto.room.AppRoomInfoDTO;
import com.yeyks.common.appcommon.json.JsonHotelExtraInfo;
import com.yeyks.common.appcommon.json.JsonImageRoom;
import com.yeyks.common.appcommon.param.room.*;
import com.yeyks.common.appcommon.result.CommonResult;
import com.yeyks.common.base.RoomInfoDevicesJson;
import com.yeyks.common.base.RoomInfoRoomInfoJson;
import com.yeyks.common.constants.AccountType;
import com.yeyks.common.constants.hotel.RoomInfoIconUrlConstant;
import com.yeyks.common.constants.hotel.RoomInfoRoomInfoJsonTypeConstant;
import com.yeyks.common.dto.mq.EsUpdateMessage;
import com.yeyks.common.em.RoomBedTypeEnum;
import com.yeyks.common.em.RoomDeviceEnum;
import com.yeyks.common.exception.OftenFiledException;
import com.yeyks.common.exception.ServiceException;
import com.yeyks.common.param.UpdateVipRoomParam;
import com.yeyks.common.utils.*;
import com.yeyks.common.utils.apputil.bean.MyBeanUtils;
import com.yeyks.common.utils.apputil.enums.BedTypeEnum;
import com.yeyks.common.utils.apputil.enums.DevicesEnum;
import com.yeyks.commonReference.append.rocketmq.service.producer.MQProducerService;
import com.yeyks.commonReference.service.hotel.HotelInfoService;
import com.yeyks.commonReference.service.hotel.RoomInfoService;
import com.yeyks.config.dal.dao.ConfigMapper;
import com.yeyks.config.dal.domain.Config;
import com.yeyks.hotel.dal.dao.HotelInfoMapper;
import com.yeyks.hotel.dal.dao.RoomCalendarJipInfoMapper;
import com.yeyks.hotel.dal.dao.RoomCalendarVipInfoMapper;
import com.yeyks.hotel.dal.dao.RoomInfoMapper;
import com.yeyks.hotel.dal.domain.*;
import com.yeyks.hotel.dto.RoomInfoDetailDTO;
import com.yeyks.hotel.service.RoomCalendarInfoService;
import com.yeyks.commonReference.service.calendar.RoomCalendarJipInfoService;
import com.yeyks.hotel.service.RoomCalendarVipInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.time.LocalDate;
import java.util.*;
import java.util.logging.Logger;


/**
 * <p>
 * 房间表 服务实现类
 * </p>
 *
 * @author yun
 * @since 2019-06-25
 */
@Service
@Slf4j
public class RoomInfoServiceImpl extends ServiceImpl<RoomInfoMapper, RoomInfo> implements RoomInfoService {
    @Autowired
    private RoomInfoMapper roomInfoMapper;

    @Autowired
    private HotelInfoMapper hotelInfoMapper;

    @Autowired
    private HotelInfoService hotelService;
    @Autowired
    private ConfigMapper configMapper;
    @Autowired
    private RoomCalendarInfoService roomCalendarInfoService;
    @Autowired
    private RoomCalendarVipInfoService roomCalendarVipInfoService;
    @Autowired
    private RoomCalendarVipInfoMapper roomCalendarVipInfoMapper;
    @Autowired
    private RoomCalendarJipInfoService roomCalendarJipInfoService;
    @Autowired
    private RoomCalendarJipInfoMapper roomCalendarJipInfoMapper;
    @Autowired
    private MQProducerService mqProducerService;

    @Override
    public RoomInfo selectByPrimaryKey(Integer roomId) {
        return roomInfoMapper.selectByPrimaryKey(roomId);
    }

    @Override
    @Transactional
    public RoomInfo addRoomInfo(RoomInfo roomInfo) {
        if (roomInfo.getCount() == null) {
            roomInfo.setCount(0);
        }
        roomInfo.setIsDel(1);
        roomInfo.setAvailable(roomInfo.getCount());
        roomInfo.setTodayTime(DateUtils.toDate(LocalDate.now()));
        //  roomInfoMapper.insertReturnId(roomInfo);
        baseMapper.insert(roomInfo);
        //初始化房态信息
        roomCalendarInfoService.initRoomCalendar(roomInfo);
        return roomInfo;
    }

    /**
     * 通过id进行删除（将isDel字段修改为0）
     *
     * @param id
     * @return
     */
    @Override
    @Transactional
    public int deleteById(Integer id, Integer isDel) {
        //停用房态信息
        roomCalendarInfoService.updateRoomCalendarStatus(id, 0);
        //停用vip房态信息
        roomCalendarVipInfoService.updateRoomCalendarStatus(id, 0);

        return roomInfoMapper.deleteAndUpdateById(id, isDel);
    }

    @Override
    @Transactional
    public AjaxResponseBody toBeVipRoom(UpdateVipRoomParam updateVipRoomParam) {
        if (null == updateVipRoomParam.getRoomId()) {
            throw new ServiceException("房间id错误");
        }
        RoomInfo roomInfo = roomInfoMapper.selectByPrimaryKey(updateVipRoomParam.getRoomId());
        if (null == roomInfo) {
            throw new ServiceException("房间信息不存在");
        }
        if (null == updateVipRoomParam.getVipPrice()) {
            throw new ServiceException("甄选酒店房的价格错误");
        }
        if (null == updateVipRoomParam.getVipDiscountPrice()) {
            throw new ServiceException("优选优惠后价错误");
        }
        Config discountConfig = configMapper.selectValueByKey("discount");
        Integer discount = Integer.valueOf(discountConfig.getValue());
        Integer lowestPrice = updateVipRoomParam.getVipPrice() * 100 / discount;
        if (updateVipRoomParam.getVipDiscountPrice() < lowestPrice) {
        //    throw new ServiceException("优选优惠后价最低为:" + lowestPrice.doubleValue() / 100);
            log.info(updateVipRoomParam.getRoomId()+",优选优惠后价最低为(超低了):" + lowestPrice.doubleValue() / 100);
        }
        if (null == updateVipRoomParam.getVipCount()) {
            throw new ServiceException("甄选酒店房数量错误");
        }

        RoomInfo roomInfoForUp = new RoomInfo();
        roomInfoForUp.setId(updateVipRoomParam.getRoomId());
        roomInfoForUp.setHotelId(roomInfo.getHotelId());
        roomInfoForUp.setVipPrice(updateVipRoomParam.getVipPrice());
        roomInfoForUp.setVipDiscountPrice(updateVipRoomParam.getVipDiscountPrice());
        roomInfoForUp.setVipCount(updateVipRoomParam.getVipCount());
        //设置节假日价格信息
        roomInfoForUp.setHolidayBuyPrice(updateVipRoomParam.getVipPrice());
        roomInfoForUp.setHolidaySalePrice(updateVipRoomParam.getVipDiscountPrice()*13/10/100*100);
        roomInfoForUp.setHolidayCount(updateVipRoomParam.getVipCount());

        roomInfoForUp.setVipAvailable(updateVipRoomParam.getVipAvailable());
        roomInfoForUp.setVipFlag(updateVipRoomParam.getVipFlag());
        roomInfoForUp.setVipStatus(1);
//        int i = roomInfoMapper.updateIfNotNullByPrimaryKey(roomInfoForUp);

        UpdateWrapper<RoomInfo> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set(RoomInfo.HOTEL_ID,roomInfo.getHotelId());
        updateWrapper.set(RoomInfo.VIP_PRICE,updateVipRoomParam.getVipPrice());
        updateWrapper.set(RoomInfo.VIP_DISCOUNT_PRICE,updateVipRoomParam.getVipDiscountPrice());
        updateWrapper.set(RoomInfo.VIP_COUNT,updateVipRoomParam.getVipCount());
        updateWrapper.set(RoomInfo.VIP_AVAILABLE,updateVipRoomParam.getVipAvailable());
        updateWrapper.set(RoomInfo.VIP_FLAG,updateVipRoomParam.getVipFlag());
        updateWrapper.set(RoomInfo.VIP_STATUS,1);
        //设置节假日价格信息
        updateWrapper.set(RoomInfo.HOLIDAY_BUY_PRICE,updateVipRoomParam.getVipPrice());
        updateWrapper.set(RoomInfo.HOLIDAY_SALE_PRICE,updateVipRoomParam.getVipDiscountPrice()*13/10/100*100);
        updateWrapper.set(RoomInfo.HOLIDAY_COUNT,updateVipRoomParam.getVipCount());
        updateWrapper.eq(RoomInfo.ID,updateVipRoomParam.getRoomId());
        boolean update = update(updateWrapper);

        if (update) {
            //查询是否有vip房态信息，有的话上架，没有的话调接口生成房态
            setRoomCalendarVipInfo(roomInfoForUp, updateVipRoomParam.getVipFlag());
            return AjaxResponseBody.success();
        } else {
            return AjaxResponseBody.failed("没有记录修改");
        }
    }

    /**
     * 查询是否有vip房态信息，有的话上架，没有的话调接口生成房态
     *
     * @param roomInfo
     * @param vipFlag
     */
    private void setRoomCalendarVipInfo(RoomInfo roomInfo, Integer vipFlag) {
        if (3 == vipFlag) //精选
        {
            int count = roomCalendarJipInfoService.count(new QueryWrapper<RoomCalendarJipInfo>().eq(RoomCalendarVipInfo.ROOM_ID, roomInfo.getId()));
            if (count == 0) {
                roomCalendarJipInfoService.initJIPRoomCalendar(roomInfo);
            } else {
                roomCalendarJipInfoService.updateRoomCalendarStatus(roomInfo.getId(), 1);
            }
//            //房态价格改为和设置时候一致
////            roomCalendarJipInfoMapper.updateRoomCalendarPrice(roomInfo.getId(), roomInfo.getVipPrice(), roomInfo.getVipDiscountPrice());
        } else { //甄选
            int roomCalendarVipInfos = roomCalendarVipInfoService.count(new QueryWrapper<RoomCalendarVipInfo>().eq(RoomCalendarVipInfo.ROOM_ID, roomInfo.getId()));
            if (roomCalendarVipInfos == 0) {
                roomCalendarVipInfoService.initVIPRoomCalendar(roomInfo);
            } else {
                roomCalendarVipInfoService.updateRoomCalendarStatus(roomInfo.getId(), 1);
            }
            //房态价格改为和设置时候一致
            roomCalendarVipInfoMapper.updateRoomCalendarPrice(roomInfo.getId(), roomInfo.getVipPrice(), roomInfo.getVipDiscountPrice());
        }
    }

    @Override
    @Transactional
    public AjaxResponseBody cancelVipRoom(Integer roomId) {
        if (null == roomId) {
            throw new ServiceException("房间id错误");
        }
        RoomInfo roomInfo = roomInfoMapper.selectByPrimaryKey(roomId);
        if (null == roomInfo) {
            throw new ServiceException("房间信息不存在");
        }
        //删除掉房态日历信息

        //先删除甄选之前的房态信息
        QueryWrapper<RoomCalendarVipInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(RoomCalendarVipInfo.ROOM_ID, roomId);
        roomCalendarVipInfoMapper.delete(queryWrapper);

//        RoomInfo roomInfoForUp = new RoomInfo();
//        roomInfoForUp.setId(roomId);
//        roomInfoForUp.setVipFlag(0);
//        int i = roomInfoMapper.updateIfNotNullByPrimaryKey(roomInfoForUp);
        UpdateWrapper<RoomInfo> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set(RoomInfo.VIP_FLAG,0);
        updateWrapper.eq(RoomInfo.ID,roomId);
        boolean update = update(updateWrapper);
        if (update) {
            //甄选房间房态下架
            roomCalendarVipInfoService.updateRoomCalendarStatus(roomId, 0);
            return AjaxResponseBody.success();
        } else {
            return AjaxResponseBody.failed("没有记录修改");
        }
    }

    @Override
    @Transactional
    public AjaxResponseBody updateVipRoomStatus(Integer roomId, Integer status) {
        int i = roomInfoMapper.update(null, new UpdateWrapper<RoomInfo>().set(RoomInfo.VIP_STATUS, status).eq(RoomInfo.ID, roomId));
        if (i > 0) {
            //甄选房间房态上下架
            roomCalendarVipInfoService.updateRoomCalendarStatus(roomId, status);
            return AjaxResponseBody.success();
        } else {
            return AjaxResponseBody.failed("vip房间上下架操作失败");
        }
    }

    @Override
    @Transactional
    public AjaxResponseBody updateJipRoomStatus(Integer roomId, Integer status) {
        int i = roomInfoMapper.update(null, new UpdateWrapper<RoomInfo>().set(RoomInfo.VIP_STATUS, status).eq(RoomInfo.ID, roomId));
        if (i > 0) {
            //甄选房间房态上下架
            roomCalendarJipInfoService.updateRoomCalendarStatus(roomId, status);
            return AjaxResponseBody.success();
        } else {
            return AjaxResponseBody.failed("优享房间上下架操作失败");
        }
    }

    /**
     * 通过roomIds获取房间信息
     *
     * @param roomIds
     * @return
     */
    @Override
    public List<RoomInfo> selectByIds(List<Integer> roomIds) {
        if (roomIds == null || roomIds.size() == 0) {
            return Lists.newArrayList();
        }
        return roomInfoMapper.selectByIds(roomIds);
    }

    @Override
    public List<RoomInfo> searchRoomByOperator(Integer loginUserId) {
        List<HotelInfo> hotelInfoList = hotelService.searchHotelsByOperator(loginUserId);

        List<Integer> ids = new ArrayList<>();
        for (HotelInfo hotelInfo : hotelInfoList) {
            ids.add(hotelInfo.getId());
        }

        return roomInfoMapper.selectByHotelIds(ids);
    }

    @Override
    public List<RoomInfo> queryRoomListByHotelId(Integer hotelId, Integer vipFlag) {
        if (1 == vipFlag) {//甄选
            return roomInfoMapper.queryVIPRoomListByHotelId(hotelId);
        } else if (3 == vipFlag) { //精选
            return roomInfoMapper.queryJIPRoomListByHotelId(hotelId);
        } else if (0 == vipFlag) { //c2b
            return roomInfoMapper.queryRoomListByHotelId(hotelId);
        } else {
            return null;
        }
    }

    @Override
    public List<RoomInfo> searchRoomByHotelId(Integer hotelId) {
        return roomInfoMapper.searchRoomByHotelId(hotelId);
    }

    /**
     * 通过房间id获取房间详情
     *
     * @param roomId
     * @return
     */
    @Override
    public RoomInfoDetailDTO roomDetail(Integer roomId) {
        RoomInfo roomInfo = baseMapper.selectById(roomId);
        if (roomInfo == null) {
            log.info("该房间不存在{}", roomId);
            throw new ServiceException("该房间信息不存在");
        }
        RoomInfoDetailDTO detailDTO = ObjectConvertUtil.convertObject(roomInfo, RoomInfoDetailDTO.class);
        String extraInfo = roomInfo.getExtraInfo();
        JSONObject jsonObject = JSONObject.parseObject(extraInfo);
        List<String> imgUrlList = (List<String>) jsonObject.get("imgUrlList");
        detailDTO.setPicUrls(imgUrlList);
        //通过房间id查询酒店
        HotelInfo hotelInfo = hotelInfoMapper.selectById(roomInfo.getHotelId());
        if (hotelInfo.getEnabledCoupon() == null) {
            hotelInfo.setEnabledCoupon(1);
        }
        detailDTO.setHotelName(hotelInfo.getName());
        detailDTO.setHotelId(hotelInfo.getId());
        detailDTO.setEnabledCoupon(hotelInfo.getEnabledCoupon());
        return detailDTO;
    }

    /**
     * 房间床型转中文
     */
    @Override
    public void roomBedTypeCn() {
        QueryWrapper<RoomInfo> wrapper = new QueryWrapper<>();
        wrapper.isNull("bed_type_cn");
        List<RoomInfo> roomInfos = baseMapper.selectList(wrapper);
        for (RoomInfo roomInfo : roomInfos) {
            if (!ArgumentsCheckUtil.strIsNull(roomInfo.getBedType())) {
                List<String> bedTypes = Splitters.splitToString(roomInfo.getBedType(), Splitters.COMMA);
                updateBedTypeCn(bedTypes, roomInfo);
            }
        }
    }

    /**
     * 设备转中文
     */
    @Override
    public void roomDevice() {
        QueryWrapper<RoomInfo> wrapper = new QueryWrapper<>();
        wrapper.isNull("devices_cn");
        List<RoomInfo> roomInfos = baseMapper.selectList(wrapper);
        for (RoomInfo roomInfo : roomInfos) {
            if (!ArgumentsCheckUtil.strIsNull(roomInfo.getDevices())) {
                List<String> devices = Splitters.splitToString(roomInfo.getDevices(), Splitters.COMMA);
                updateDeviceCn(devices, roomInfo);
            }
        }
    }

    /**
     * 根据指定条件查询C2b房间对象
     *
     * @param map
     * @return
     */
    @Override
    public List<RoomInfo> getRoomInfos(Map<String, Object> map) {
        return baseMapper.getRoomInfos(map);
    }


    private void updateBedTypeCn(List<String> bedTypes, RoomInfo roomInfo) {
        List<String> bedTypeCns = Lists.newArrayList();
        for (String bedType : bedTypes) {
            bedTypeCns.add(RoomBedTypeEnum.getDesc(bedType));
        }
        String bedTypeCn = Joiners.COMMA.join(bedTypeCns);
        roomInfo.setBedTypeCn(bedTypeCn);
        baseMapper.updateById(roomInfo);
    }

    private void updateDeviceCn(List<String> devices, RoomInfo roomInfo) {
        List<String> deviceCns = Lists.newArrayList();
        for (String device : devices) {
            deviceCns.add(RoomDeviceEnum.getDesc(device));
        }
        String deviceCn = Joiners.COMMA.join(deviceCns);
        roomInfo.setDevicesCn(deviceCn);
        baseMapper.updateById(roomInfo);
    }

    //====================admin - app 客房的相关接口实现 ===========================

    @Override
    public CommonResult<List<AppRoomBedTypeDTO>> getBedTypeList(AccountInfo accountInfo) {

        List<AppRoomBedTypeDTO> appRoomBedTypeDTOList = Lists.newArrayList();

        System.out.println(JSONObject.toJSONString(BedTypeEnum.values()) + "数据");

        List<BedTypeEnum> b = Arrays.asList(BedTypeEnum.values());

        b.forEach(bedTypeEnum -> {
            AppRoomBedTypeDTO bedTypeDTO = new AppRoomBedTypeDTO();
            bedTypeDTO.setType(bedTypeEnum.getEn());
            bedTypeDTO.setValue(bedTypeEnum.getCn());
            appRoomBedTypeDTOList.add(bedTypeDTO);
        });
        return CommonResult.success(appRoomBedTypeDTOList);
    }

    @Override
    public CommonResult<List<AppRoomDevicesDTO>> getDevicesList(AccountInfo accountInfo) {

        List<AppRoomDevicesDTO> appRoomDevicesDTOList = Lists.newArrayList();

        List<DevicesEnum> d = Arrays.asList(DevicesEnum.values());
        d.forEach(devicesEnum -> {
            AppRoomDevicesDTO appRoomDevicesDTO = new AppRoomDevicesDTO();
            appRoomDevicesDTO.setType(devicesEnum.getEn());
            appRoomDevicesDTO.setValue(devicesEnum.getCn());
            appRoomDevicesDTOList.add(appRoomDevicesDTO);
        });

        return CommonResult.success(appRoomDevicesDTOList);
    }

    @Override
    public CommonResult<List<RoomInfoRoomInfoJson>> getRoomInfoJsonList(AccountInfo convert) {
        List<RoomInfoRoomInfoJson> roomInfoRoomInfoJsons = Lists.newArrayList();

        System.out.println(JSONObject.toJSONString(BedTypeEnum.values()) + "数据");

        List<BedTypeEnum> b = Arrays.asList(BedTypeEnum.values());

        b.forEach(bedTypeEnum -> {
            RoomInfoRoomInfoJson roomInfoJson = new RoomInfoRoomInfoJson();
            roomInfoJson.setName(bedTypeEnum.getCn());
            roomInfoJson.setIcon(RoomInfoIconUrlConstant.BED_TYPE);
            roomInfoJson.setType(RoomInfoRoomInfoJsonTypeConstant.BED_TYPE);
            roomInfoJson.setValue(bedTypeEnum.getEn());
            roomInfoRoomInfoJsons.add(roomInfoJson);
        });
        return CommonResult.success(roomInfoRoomInfoJsons);
    }

    @Override
    public CommonResult<List<RoomInfoDevicesJson>> getDevicesJsonList(AccountInfo convert) {
        List<RoomInfoDevicesJson> roomInfoDevicesJsons = Lists.newArrayList();

        List<DevicesEnum> d = Arrays.asList(DevicesEnum.values());
        d.forEach(devicesEnum -> {
            RoomInfoDevicesJson roomInfoDevicesJson = new RoomInfoDevicesJson();
            roomInfoDevicesJson.setName(devicesEnum.getCn());
            roomInfoDevicesJson.setIcon(RoomInfoIconUrlConstant.RIGHT);
            roomInfoDevicesJsons.add(roomInfoDevicesJson);
        });

        return CommonResult.success(roomInfoDevicesJsons);
    }

    @Override
    public CommonResult<List<AppRoomInfoDTO>> pageList(QueryRoomParam queryRoomParam, AccountInfo accountInfo) {

        HotelInfo hotelInfo = null;
        //得到酒店对象信息
        if (null != queryRoomParam.getHotelId()) {
            hotelInfo = hotelInfoMapper.selectOne(new QueryWrapper<HotelInfo>().eq(HotelInfo.ID, queryRoomParam.getHotelId()));
        } else if (null != accountInfo && accountInfo.getType() == AccountType.HotelManager) {
            if (accountInfo.getManagerId() != null) {
                accountInfo.setId(accountInfo.getManagerId());
            }
            hotelInfo = hotelInfoMapper.selectByHotelManager(accountInfo.getId());
        }
        if (null != hotelInfo) {
            QueryWrapper<RoomInfo> roomInfoQueryWrapper = new QueryWrapper<RoomInfo>()
                    .eq(RoomInfo.HOTEL_ID, hotelInfo.getId())
                    .eq(RoomInfo.IS_DEL, 1);
            if (queryRoomParam.getVipFlag() != null) {
                roomInfoQueryWrapper.eq(RoomInfo.VIP_FLAG, queryRoomParam.getVipFlag());
            }
            roomInfoQueryWrapper.orderByDesc(RoomInfo.ID);

            List<RoomInfo> appRoomInfoList = roomInfoMapper.selectList(roomInfoQueryWrapper);
            if (!CollectionUtils.isEmpty(appRoomInfoList)) {
                List<AppRoomInfoDTO> appRoomInfoDTOList = MyBeanUtils.convertArrayList(appRoomInfoList, AppRoomInfoDTO.class);
                //调用补全详情
                convertOtherRoomDetail(hotelInfo.getId(), appRoomInfoDTOList);
                return CommonResult.success(appRoomInfoDTOList);
            }
        }
        return CommonResult.success(Lists.newArrayList(), "数据为空");
    }

    /**
     * 详情信息补全
     * @param hotelId
     * @param appRoomInfoDTOList
     */
    private void convertOtherRoomDetail(Integer hotelId, List<AppRoomInfoDTO> appRoomInfoDTOList){
        List<Integer> roomIds = Lists.newArrayList();
        List<Integer> jipRoomIds = Lists.newArrayList();
        //存入图片信息
        if(!CollectionUtils.isEmpty(appRoomInfoDTOList)){
            appRoomInfoDTOList.forEach(appRoomInfoDTO -> {
                JsonImageRoom imageHotel = JSONObject.parseObject(appRoomInfoDTO.getExtraInfo(), JsonImageRoom.class);
                appRoomInfoDTO.setPicUrls(imageHotel.getImgUrlList());
                appRoomInfoDTO.setDefaultBottomPrice(appRoomInfoDTO.getBottomPrice());
                appRoomInfoDTO.setDefaultCount(appRoomInfoDTO.getCount());
                appRoomInfoDTO.setDefaultCurPrice(appRoomInfoDTO.getCurPrice());
                //【优享VIP默认价格】
                appRoomInfoDTO.setDefaultVipCount(appRoomInfoDTO.getVipCount());
                appRoomInfoDTO.setDefaultVipPrice(appRoomInfoDTO.getVipPrice());
                appRoomInfoDTO.setDefaultVipDiscountPrice(appRoomInfoDTO.getVipDiscountPrice());
                roomIds.add(appRoomInfoDTO.getId());
                if (appRoomInfoDTO.getVipFlag() == 3) {
                    jipRoomIds.add(appRoomInfoDTO.getId());
                }

            });
        }
        //得到今日的现价，数量 和 抢单底价(优化查询信息)
        Map<Integer, RoomCalendarInfo> calendarInfoMap = Maps.newHashMap();
        List<RoomCalendarInfo> calendarInfoList = this.getTodayRoomListCalendar(hotelId, roomIds);
        if(!CollectionUtils.isEmpty(calendarInfoList)){
            for (RoomCalendarInfo roomCalendarInfo : calendarInfoList) {
                calendarInfoMap.put(roomCalendarInfo.getRoomId(), roomCalendarInfo);
            }
        }
        //【优享最新数据】循环存入数据
        Map<Integer, RoomCalendarJipInfo> jipCalendarInfoMap = Maps.newHashMap();
        List<RoomCalendarJipInfo> calendarJipInfoList = this.getTodayRoomListCalendarJip(hotelId, jipRoomIds);
        if(!CollectionUtils.isEmpty(calendarJipInfoList)){
            for (RoomCalendarJipInfo roomCalendarJipInfo : calendarJipInfoList) {
                jipCalendarInfoMap.put(roomCalendarJipInfo.getRoomId(), roomCalendarJipInfo);
            }
        }
        //最新价格
        convertNewPrice(calendarInfoMap, jipCalendarInfoMap, appRoomInfoDTOList);
    }

    /**
     * 房间列表【当天】价格更新
     * @param calendarInfoMap
     * @param jipCalendarInfoMap
     * @param appRoomInfoDTOList
     */
    private void convertNewPrice(Map<Integer, RoomCalendarInfo> calendarInfoMap,
                                 Map<Integer, RoomCalendarJipInfo> jipCalendarInfoMap,
                                 List<AppRoomInfoDTO> appRoomInfoDTOList){
        if(!CollectionUtils.isEmpty(appRoomInfoDTOList)){
            for (AppRoomInfoDTO roomInfoDTO : appRoomInfoDTOList) {
                //给优享插入价格信息
                if (roomInfoDTO.getVipFlag() == 3) {
                    if (!org.springframework.util.CollectionUtils.isEmpty((jipCalendarInfoMap))) {
                        RoomCalendarJipInfo calendarJipInfo = jipCalendarInfoMap.get(roomInfoDTO.getId());
                        if (null != calendarJipInfo) {
                            roomInfoDTO.setVipCount(calendarJipInfo.getCount());
                            roomInfoDTO.setVipAvailable(calendarJipInfo.getCount() - calendarJipInfo.getLockCount());
                            roomInfoDTO.setVipDiscountPrice(calendarJipInfo.getSalePrice());
                            roomInfoDTO.setVipPrice(calendarJipInfo.getPurcPrice());
                            roomInfoDTO.setVipStatus(calendarJipInfo.getStatus());
                        } else {
                            roomInfoDTO.setVipAvailable(roomInfoDTO.getDefaultVipCount() - roomInfoDTO.getVipAvailable());
                        }
                    } else {
                        roomInfoDTO.setVipAvailable(roomInfoDTO.getDefaultVipCount() - roomInfoDTO.getVipAvailable());
                    }
                }
                if (!org.springframework.util.CollectionUtils.isEmpty(calendarInfoMap)) {
                    RoomCalendarInfo calendarInfo = calendarInfoMap.get(roomInfoDTO.getId());
                    if (null != calendarInfo) {
                        if (calendarInfo.getBottomPrice() == null) {
                            roomInfoDTO.setBottomPrice(calendarInfo.getSalePrice());
                        } else {
                            roomInfoDTO.setBottomPrice(calendarInfo.getBottomPrice());
                        }
                        roomInfoDTO.setCurPrice(calendarInfo.getSalePrice());
                        roomInfoDTO.setCount(calendarInfo.getCount());
                        roomInfoDTO.setAvailable(calendarInfo.getCount() - calendarInfo.getLockCount());
                        roomInfoDTO.setValid(calendarInfo.getStatus() == 1);
                    } else {
                        //如果为空，需要个可用房间数设置默认值
                        roomInfoDTO.setAvailable(roomInfoDTO.getDefaultCount() - roomInfoDTO.getAvailable());
                    }
                } else {
                    //如果map为空，设置默认信息
                    roomInfoDTO.setAvailable(roomInfoDTO.getDefaultCount() - roomInfoDTO.getAvailable());
                }
            }
        }
    }

    @Override
    public CommonResult addRoom(AddRoomInfoParam addRoomInfoParam, AccountInfo accountInfo) {
        //存入返回信息
        Map<String, Object> map = Maps.newHashMap();
        int count = 0;
        if (null != accountInfo) {
            //参数转换
            RoomInfo appRoomInfo = this.convertAddRoom(addRoomInfoParam, accountInfo);
            count = baseMapper.insert(appRoomInfo);
            if (count > 0) {
                Integer versionParam = Integer.valueOf(addRoomInfoParam.getVersion().replace(".", "").trim());
                //当版本大于1.4.1的时候在进行返回参数
                if (versionParam > 141) {
                    map.put("roomId", appRoomInfo.getId());
                    map.put("hotelId", appRoomInfo.getHotelId());
                } else {
                    map = null;
                }
                //是否添加三十天的信息
                AddRoomCalendarParam addRoomCalendarParam = new AddRoomCalendarParam();
                addRoomCalendarParam.setHotelId(appRoomInfo.getHotelId());
                addRoomCalendarParam.setRoomId(appRoomInfo.getId());
                AppAccountDTO appAccountDTO = MyBeanUtils.convert(accountInfo, AppAccountDTO.class);
                roomCalendarInfoService.addRoomCalendar(addRoomCalendarParam, appAccountDTO);

                //发送MQ 更新ES
                List<String> sourceIds = Lists.newArrayList();
                sourceIds.add(String.valueOf(appRoomInfo.getId()));
                mqProducerService.sendEsUpdate(new EsUpdateMessage().setType("room").setSourceType("yyks")
                        .setSourceIds(sourceIds), 0);
                return CommonResult.success(map, "操作数据成功");
            }
        }
        return CommonResult.failed("添加数据失败!");
    }

    @Override
    public CommonResult<AppRoomDetailInfoDTO> getRoom(GetRoomParam getRoomParam, AccountInfo accountInfo) {

        RoomInfo appRoomInfo = roomInfoMapper.selectByPrimaryKey(getRoomParam.getId());
        if (null != appRoomInfo) {
            AppRoomDetailInfoDTO roomInfoDTO = MyBeanUtils.convert(appRoomInfo, AppRoomDetailInfoDTO.class);
            JsonImageRoom imageHotel = JSONObject.parseObject(roomInfoDTO.getExtraInfo(), JsonImageRoom.class);
            roomInfoDTO.setPicUrls(imageHotel.getImgUrlList());
            roomInfoDTO.setDefaultBottomPrice(roomInfoDTO.getBottomPrice());
            roomInfoDTO.setDefaultCount(roomInfoDTO.getCount());
            roomInfoDTO.setDefaultCurPrice(roomInfoDTO.getCurPrice());
            roomInfoDTO.setDefaultVipDiscountPrice(roomInfoDTO.getVipDiscountPrice());
            roomInfoDTO.setDefaultVipPrice(roomInfoDTO.getVipPrice());
            roomInfoDTO.setDefaultVipCount(roomInfoDTO.getVipCount());
            //得到普通今日的现价，数量 和 抢单底价
            RoomCalendarInfo calendarInfo = this.getTodayRoomCalendar(appRoomInfo.getHotelId(), getRoomParam.getId());
            if (null != calendarInfo) {
                roomInfoDTO.setBottomPrice(calendarInfo.getBottomPrice());
                roomInfoDTO.setCurPrice(calendarInfo.getSalePrice());
                roomInfoDTO.setCount(calendarInfo.getCount());
                roomInfoDTO.setAvailable(calendarInfo.getCount() - calendarInfo.getLockCount());
            }
            //【优享客房】，最新价格
            if (appRoomInfo.getVipFlag() == 3) {
                RoomCalendarJipInfo todayRoomCalendarJip = this.getTodayRoomCalendarJip(appRoomInfo.getHotelId(), getRoomParam.getId());
                if (null != todayRoomCalendarJip) {
                    roomInfoDTO.setVipDiscountPrice(todayRoomCalendarJip.getSalePrice());
                    roomInfoDTO.setVipPrice(todayRoomCalendarJip.getPurcPrice());
                    roomInfoDTO.setVipCount((todayRoomCalendarJip.getCount()));
                    roomInfoDTO.setVipAvailable(todayRoomCalendarJip.getCount() - todayRoomCalendarJip.getLockCount());
                }
            }
            //JSON转换集合
            List<RoomInfoRoomInfoJson> roomInfoRoomInfoJsons = JSON.parseArray(appRoomInfo.getRoomInfoJson(), RoomInfoRoomInfoJson.class);
            //移除不是bedType的数据
            if(!CollectionUtils.isEmpty(roomInfoRoomInfoJsons)){
                roomInfoRoomInfoJsons.removeIf(roomInfoRoomInfoJson ->
                        !RoomInfoRoomInfoJsonTypeConstant.BED_TYPE.equals(roomInfoRoomInfoJson.getType()));
            }
            roomInfoDTO.setRoomInfoJson(roomInfoRoomInfoJsons);
            roomInfoDTO.setDevicesJson(JSON.parseArray(appRoomInfo.getDevicesJson(), RoomInfoDevicesJson.class));
            return CommonResult.success(roomInfoDTO);
        }
        return CommonResult.failed("没有该数据!");
    }

    @Override
    public CommonResult delRoom(DelRoomParam delRoomParam, AccountInfo accountInfo) {

        //查询是否有客房
        RoomInfo roomInfo = roomInfoMapper.selectByPrimaryKey(delRoomParam.getId());
        if (null != roomInfo) {
            //是否已经删除
            if (roomInfo.getIsDel() == 0) {
                return CommonResult.failed("该数据已经删除");
            }
            //执行删除
            roomInfo.setIsDel(0);
            int count = roomInfoMapper.updateByPrimaryKey(roomInfo);
            if (count > 0) {
                //停用房态信息
                roomCalendarInfoService.updateRoomCalendarStatus(delRoomParam.getId(), 0);
                //停用vip房态信息
                roomCalendarVipInfoService.updateRoomCalendarStatus(delRoomParam.getId(), 0);

                //发送MQ 更新ES
                List<String> sourceIds = Lists.newArrayList();
                sourceIds.add(String.valueOf(roomInfo.getId()));
                mqProducerService.sendEsUpdate(new EsUpdateMessage().setType("room").setSourceType("yyks")
                        .setSourceIds(sourceIds), 0);
                return CommonResult.success(null, "删除客房成功!");
            }
        }
        return CommonResult.failed("删除操作失败!");
    }

    @Override
    public CommonResult validRoom(UpdateValidRoomParam validRoomParam, AccountInfo accountInfo) {

        RoomInfo appRoomInfo = roomInfoMapper.selectByPrimaryKey(validRoomParam.getId());
        //查询当天的上下架状态，然后进行修改
        if (null != appRoomInfo) {
            RoomCalendarInfo todayRoomCalendar = this.getTodayRoomCalendar(appRoomInfo.getHotelId(), appRoomInfo.getId());
            int status = 0;
            if (null != todayRoomCalendar) {
                if (todayRoomCalendar.getStatus() == 1) {
                    appRoomInfo.setValid(false);
                } else {
                    status = 1;
                    appRoomInfo.setValid(true);
                }
            } else {
                if (appRoomInfo.getValid()) {
                    appRoomInfo.setValid(false);
                } else {
                    status = 1;
                    appRoomInfo.setValid(true);
                }
            }
            int count = roomInfoMapper.updateById(appRoomInfo);
            if (count > 0) {
                //更新所有的客房日历状态信息
                roomCalendarInfoService.updateRoomCalendarStatusList(Collections.singletonList(validRoomParam.getId()),
                        status);

                //发送MQ 更新ES
                List<String> sourceIds = Lists.newArrayList();
                sourceIds.add(String.valueOf(appRoomInfo.getId()));
                mqProducerService.sendEsUpdate(new EsUpdateMessage().setType("room").setSourceType("yyks")
                        .setSourceIds(sourceIds), 0);
                return CommonResult.success(null, "操作成功");
            }
        }
        return CommonResult.failed("操作失败!");
    }

    @Override
    public CommonResult updateAnyParamRoom(UpdateRoomInfoParam param, AccountInfo accountInfo) {

        int count = 0;
        RoomInfo selRoom = roomInfoMapper.selectByPrimaryKey(param.getId());
        if (null != selRoom && null != accountInfo) {
            AddRoomInfoParam addRoomInfoParam = MyBeanUtils.convert(param, AddRoomInfoParam.class);
            RoomInfo appRoomInfo = this.convertAddRoom(addRoomInfoParam, accountInfo);
            //主键
            appRoomInfo.setId(param.getId());
            appRoomInfo.setVipDiscountPrice(param.getVipDiscountPrice());
            appRoomInfo.setVipCount(param.getVipCount());
            appRoomInfo.setVipPrice(param.getVipPrice());
            count = roomInfoMapper.updateById(appRoomInfo);
        }

        if (count > 0) {
            String now = DateUtils.getDateForDay(0);
            String month = DateUtils.getDateForDay(29);
            if (selRoom.getVipFlag() == 3) {
                //更新优享VIP的房态信息
                if (null == param.getVipPrice()) {
                    throw new OftenFiledException("甄选酒店房的价格错误");
                }
                if (null == param.getVipDiscountPrice()) {
                    throw new OftenFiledException("优选优惠后价错误");
                }
                Config discountConfig = configMapper.selectValueByKey("discount");
                Integer discount = Integer.valueOf(discountConfig.getValue());
                Integer lowestPrice = param.getVipPrice() * 100 / discount;
                if (param.getVipDiscountPrice() < lowestPrice) {
                    throw new OftenFiledException("优选优惠后价最低为:" + lowestPrice.doubleValue() / 100);
                }
                if (null == param.getVipCount()) {
                    throw new OftenFiledException("甄选酒店房数量错误");
                }
                //更新优享VIP 的 30天的默认数据信息
                roomCalendarJipInfoService.update(new RoomCalendarJipInfo()
                                .setCount(param.getVipCount())
                                .setPurcPrice(param.getVipPrice())
                                .setSalePrice(param.getVipDiscountPrice())
                        , new UpdateWrapper<RoomCalendarJipInfo>()
                                .eq(RoomCalendarJipInfo.ROOM_ID, param.getId())
                                .between(RoomCalendarInfo.DATE, now, month));
                return CommonResult.success(null, "操作数据成功");
            } else {
                //更新C2B的30天的默认数据信息
                roomCalendarInfoService.update(new RoomCalendarInfo()
                                .setBottomPrice(param.getBottomPrice())
                                .setSalePrice(param.getCurPrice())
                                .setCount(param.getCount())
                        , new UpdateWrapper<RoomCalendarInfo>()
                                .eq(RoomCalendarInfo.ROOM_ID, param.getId())
                                .between(RoomCalendarInfo.DATE, now, month));
                //发送MQ 更新ES
                List<String> sourceIds = Lists.newArrayList();
                sourceIds.add(String.valueOf(selRoom.getId()));
                mqProducerService.sendEsUpdate(new EsUpdateMessage().setType("room").setSourceType("yyks")
                        .setSourceIds(sourceIds), 0);
                return CommonResult.success(null, "操作数据成功");
            }
        }
        return CommonResult.failed("更新数据失败!");
    }

    @Override
    public CommonResult updateRoom(UpdateRoomInfoParam updateRoomInfoParam, AccountInfo accountInfo) {
        //查询房间是否存在
        int count = 0;
        RoomInfo selRoom = roomInfoMapper.selectByPrimaryKey(updateRoomInfoParam.getId());
        if (null != selRoom && null != accountInfo) {
            AddRoomInfoParam addRoomInfoParam = MyBeanUtils.convert(updateRoomInfoParam, AddRoomInfoParam.class);
            RoomInfo appRoomInfo = this.convertAddRoom(addRoomInfoParam, accountInfo);
            //主键
            appRoomInfo.setId(updateRoomInfoParam.getId());
            count = roomInfoMapper.updateById(appRoomInfo);
        }

        if (count > 0) {
            //发送MQ 更新ES
            List<String> sourceIds = Lists.newArrayList();
            sourceIds.add(String.valueOf(selRoom.getId()));
            mqProducerService.sendEsUpdate(new EsUpdateMessage().setType("room").setSourceType("yyks")
                    .setSourceIds(sourceIds), 0);
            return CommonResult.success(null, "操作数据成功");
        }
        return CommonResult.failed("更新数据失败!");
    }

    /**
     * 上下架优享VIP酒店
     *
     * @param updateValidRoomParam
     * @param convert
     * @return
     */
    @Override
    public CommonResult validRoomMinVip(UpdateValidRoomParam updateValidRoomParam, AccountInfo convert) {

        RoomInfo appRoomInfo = roomInfoMapper.selectByPrimaryKey(updateValidRoomParam.getId());
        //查询当天的上下架状态，然后进行修改
        if (null != appRoomInfo) {
            RoomCalendarJipInfo todayRoomCalendar = this.getTodayRoomCalendarJip(appRoomInfo.getHotelId(), appRoomInfo.getId());
            int status = 0;
            if (null != todayRoomCalendar) {
                if (todayRoomCalendar.getStatus() == 1) {
                    appRoomInfo.setVipStatus(0);
                } else {
                    status = 1;
                    appRoomInfo.setVipStatus(1);
                }
            } else {
                if (appRoomInfo.getVipStatus() == 1) {
                    appRoomInfo.setVipStatus(0);
                } else {
                    status = 1;
                    appRoomInfo.setVipStatus(1);
                }
            }
            int count = roomInfoMapper.updateById(appRoomInfo);
            if (count > 0) {
                //更新所有的客房日历状态信息
                roomCalendarJipInfoService.updateRoomCalendarStatus(updateValidRoomParam.getId(),
                        status);

                //TODO 发送MQ 更新ES（Jip 的房态信息是否需要存入ES中）
//                List<String> sourceIds = Lists.newArrayList();
//                sourceIds.add(String.valueOf(appRoomInfo.getId()));
//                mqProducerService.sendEsUpdate(new EsUpdateMessage().setType("room").setSourceType("yyks")
//                        .setSourceIds(sourceIds),0);
                return CommonResult.success(null, "操作成功");
            }
        }
        return CommonResult.failed("更新数据失败!");
    }

    /**
     * 升级优享VIP客房
     *
     * @param param       输入参数
     * @param accountInfo 操作人
     * @return
     */
    @Override
    public CommonResult upgradeJipRoom(UpdateUpgradeMinVipParam param, AccountInfo accountInfo) {

        UpdateVipRoomParam vipRoomParam = new UpdateVipRoomParam();
        //3表示VIP客房
        vipRoomParam.setVipFlag(3);
        vipRoomParam.setVipPrice(param.getVipPrice());
        vipRoomParam.setVipAvailable(param.getVipAvailable());
        vipRoomParam.setVipDiscountPrice(param.getVipDiscountPrice());
        vipRoomParam.setRoomId(param.getRoomId());
        vipRoomParam.setVipCount(param.getVipCount());
        try {
            AjaxResponseBody body = this.toBeVipRoom(vipRoomParam);
            if (body.getCode() == 0) {
                return CommonResult.success("升级VIP客房成功");
            } else {
                return CommonResult.failed(body.getMsg());
            }
        } catch (ServiceException e) {
            throw new OftenFiledException(e.getMessage());
        }
    }

    /**
     * 输入参数拼接转换
     *
     * @param addRoomInfoParam 添加客房输入参数
     * @param accountInfo      添加账号
     * @return
     */
    private RoomInfo convertAddRoom(AddRoomInfoParam addRoomInfoParam, AccountInfo accountInfo) {
        RoomInfo appRoomInfo = new RoomInfo();
        if (null != addRoomInfoParam) {

            HotelInfo hotelInfo = hotelInfoMapper.selectByHotelManager(accountInfo.getId());
            if (null != hotelInfo) {
                //所属酒店
                addRoomInfoParam.setHotelId(hotelInfo.getId());
                appRoomInfo = MyBeanUtils.convert(addRoomInfoParam, RoomInfo.class);

                //客房信息
                if(!StringUtils.isEmpty(appRoomInfo.getRoomInfoJson())){
                    List<RoomInfoRoomInfoJson> roomInfoRoomInfoJsonList = JSON.parseArray(appRoomInfo.getRoomInfoJson(),
                            RoomInfoRoomInfoJson.class);
                    appRoomInfo.setBedType(roomInfoRoomInfoJsonList.get(0).getValue());
                    appRoomInfo.setBedTypeCn(roomInfoRoomInfoJsonList.get(0).getName());
                    if(CollectionUtils.isEmpty(roomInfoRoomInfoJsonList)){
                        roomInfoRoomInfoJsonList = Lists.newArrayList();
                    }
                    //面积
                    if(appRoomInfo.getArea() != null){
                        String acreage = appRoomInfo.getArea() + "m²";
                        if(appRoomInfo.getArea() == 0){
                            acreage = "到店查看";
                        }
                        RoomInfoRoomInfoJson areas = new RoomInfoRoomInfoJson(acreage,
                                RoomInfoIconUrlConstant.AREA,
                                RoomInfoRoomInfoJsonTypeConstant.AREA,
                                appRoomInfo.getArea().toString());
                        roomInfoRoomInfoJsonList.add(areas);
                    }
                    //人数
                    if(appRoomInfo.getMaxPeople() != null){
                        String maxAdult = "最多可住" + appRoomInfo.getMaxPeople() + "人";
                        if(appRoomInfo.getMaxPeople() == 0){
                            maxAdult = "到店查看";
                        }
                        RoomInfoRoomInfoJson maxPerson = new RoomInfoRoomInfoJson(maxAdult,
                                RoomInfoIconUrlConstant.PEOPLE_NUMBER,
                                RoomInfoRoomInfoJsonTypeConstant.PEOPLE_NUMBER,
                                appRoomInfo.getMaxPeople().toString());
                        roomInfoRoomInfoJsonList.add(maxPerson);
                    }
                    //楼层
                    if(!StringUtils.isEmpty(appRoomInfo.getFloor())){
                        String floors = appRoomInfo.getFloor() + "层";
                        if(appRoomInfo.getFloor() == 0){
                            floors = "到店查看";
                        }
                        RoomInfoRoomInfoJson floor = new RoomInfoRoomInfoJson(floors,
                                RoomInfoIconUrlConstant.FLOOR,
                                RoomInfoRoomInfoJsonTypeConstant.FLOOR,
                                appRoomInfo.getFloor().toString());
                        roomInfoRoomInfoJsonList.add(floor);
                    }
                    //存入客房信息
                    appRoomInfo.setRoomInfoJson(JSON.toJSONString(roomInfoRoomInfoJsonList));
                }
                //每天剩余
                appRoomInfo.setAvailable(addRoomInfoParam.getAvailable());
                //默认1，代表未删除，0代表已删除
                appRoomInfo.setIsDel(1);
                //每次下单时判断当前时间是否等于该值,存入的是当前时间 00:00:00
                appRoomInfo.setTodayTime(DateUtils.toDate(LocalDate.now()));
                //扩展信息[包含图片，设备等信息]
                if (!org.springframework.util.CollectionUtils.isEmpty(addRoomInfoParam.getImageUrls())) {
                    JsonHotelExtraInfo hotelExtraInfo = new JsonHotelExtraInfo();
                    hotelExtraInfo.setImgUrlList(addRoomInfoParam.getImageUrls());
                    appRoomInfo.setExtraInfo(JSONObject.toJSONString(hotelExtraInfo));
                }
                //设置默认底价
                if (null == addRoomInfoParam.getBottomPrice()) {
                    appRoomInfo.setBottomPrice(addRoomInfoParam.getCurPrice());
                }
            }
        }
        return appRoomInfo;
    }

    /**
     * 得到批量最新的客房数据信息
     *
     * @param hotelId 酒店ID
     * @param roomIds 房间集合Id
     * @return 返回单个对象
     */
    private List<RoomCalendarInfo> getTodayRoomListCalendar(Integer hotelId, List<Integer> roomIds) {

        QueryWrapper<RoomCalendarInfo> eq = new QueryWrapper<RoomCalendarInfo>()
                .eq(RoomCalendarInfo.HOTEL_ID, hotelId);
        if(CollectionUtils.isEmpty(roomIds)){
            return null;
        }else{
            eq.in(RoomCalendarInfo.ROOM_ID, roomIds)
                    .eq(RoomCalendarInfo.DATE, DateUtils.dateToyyyyMMdd(new Date()));
        }
        return roomCalendarInfoService.list(eq);
    }

    /**
     * 得到批量最新的【优享VIP】客房数据信息
     *
     * @param hotelId 酒店ID
     * @param roomIds 房间IDs
     * @return 返回单个对象
     */
    private List<RoomCalendarJipInfo> getTodayRoomListCalendarJip(Integer hotelId, List<Integer> roomIds) {

        QueryWrapper<RoomCalendarJipInfo> eq = new QueryWrapper<RoomCalendarJipInfo>()
                .eq(RoomCalendarJipInfo.HOTEL_ID, hotelId);
        if(CollectionUtils.isEmpty(roomIds)){
            return null;
        }else{
            eq.in(RoomCalendarJipInfo.ROOM_ID, roomIds)
                    .eq(RoomCalendarJipInfo.DATE, DateUtils.dateToyyyyMMdd(new Date()));
        }
        return roomCalendarJipInfoService.list(eq);
    }

    /**
     * 得到单条最新的客房数据信息
     *
     * @param hotelId 酒店ID
     * @param roomId  房间Id
     * @return 返回单个对象
     */
    private RoomCalendarInfo getTodayRoomCalendar(Integer hotelId, Integer roomId) {

        QueryWrapper<RoomCalendarInfo> eq = new QueryWrapper<RoomCalendarInfo>()
                .eq(RoomCalendarInfo.HOTEL_ID, hotelId);
        if(null == roomId){
            return null;
        }else {
            eq.eq(RoomCalendarInfo.ROOM_ID, roomId)
                    .eq(RoomCalendarInfo.DATE, DateUtils.dateToyyyyMMdd(new Date()));
        }
        return roomCalendarInfoService.getOne(eq);
    }

    /**
     * 得到单条最新的【优享VIP】客房数据信息
     *
     * @param hotelId 酒店ID
     * @param roomId  房间ID
     * @return 返回单个对象
     */
    private RoomCalendarJipInfo getTodayRoomCalendarJip(Integer hotelId, Integer roomId) {

        QueryWrapper<RoomCalendarJipInfo> eq = new QueryWrapper<RoomCalendarJipInfo>()
                .eq(RoomCalendarJipInfo.HOTEL_ID, hotelId);
        if(null == roomId){
            return null;
        }else{
            eq.eq(RoomCalendarJipInfo.ROOM_ID, roomId)
                    .eq(RoomCalendarJipInfo.DATE, DateUtils.dateToyyyyMMdd(new Date()));
        }
        return roomCalendarJipInfoService.getOne(eq);
    }
}
